<template>
<!-- 包装 -->
  <div class="swiper">
    <div class="swiper-wrapper">
        <slot></slot>
    </div>
    <!-- 分页器 -->
    <div class="swiper-pagination"></div>
  </div>
</template>
<script>
import Swiper from 'swiper/bundle' // 导入所有模块
import 'swiper/swiper-bundle.css'
export default {
  props: {
    loop: {
      type: Boolean,
      default: true
    }
  },
  mounted () {
    new Swiper('.swiper', {
      direction: 'horizontal', // 横向切换选项
      loop: this.loop, // 循环模式选项

      // 如果需要分页器
      pagination: {
        el: '.swiper-pagination'
      },
      // 自动轮播
      autoplay: {
        delay: 2500,
        disableOnInteraction: false // 在交互时禁用
      }
    })
  }
}

</script>
<style>
.swiper{
  width: 100%;
  position: relative;
  overflow: hidden;
}
.swiper .swiper-pagination{
  width: 8.25rem;
  position: absolute;
  bottom:0;
  left: 36.625rem;
  right: 0;
}
:root{
  --swiper-theme-color:white;
}
</style>
